package com.ruoyi.web.controller.common;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.Getter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import static com.ruoyi.web.controller.common.MatchUtil.HUANG_LI_DAY;

/**
 * @Description 微信接受信息事件枚举
 * @Author gc
 * @Date
 */
@Getter
public enum RobotFeatureEnum {
    /**
     *
     * */
    TIAN_GOU("tiangou","舔狗日记"),
    /**
     *
     * */
    SAY_LOVE("saylove","土味情话"),
    /**
     *
     * */
    STORY("story","故事大全"),
    /**
     *
     * */
    JOKER("joker","笑话"),
    /**
     *
     * */
    SEXY_PIC("sexy_pic","清凉一夏"),
    /**
     *
     * */
    CAIHONGPI("caihongpi","彩虹屁"),
    /**
     * 同CAIHONGPI
     * */
    KUAWO("caihongpi","夸我"),
    /**
     *
     * */
    ZAOAN("zaoan","早安"),
    /**
     * 同ZAOAN
     * */
    MORNING("zaoan","早上好"),
    /**
     *
     * */
    WANAN("wanan","晚安"),
    /**
     *
     * */
    DUJITANG("dujitang","毒鸡汤"),
    /**
     *
     * */
    CANGTOUSHI("cangtoushi","藏头诗"),
    /**
     *
     * */
    WOXIANGTING("music","我想听"),
    /**
     *
     * */
    MUSIC("music","点歌"),
    /**
     *
     * */
    DOUYIN_VIDEO("video","抖音唱歌小姐姐"),
    /**
     *
     * */
    LUNAR("lunar","日历"),
    /**
     *
     * */
    STOCK("stock","股票"),
    /**
     *
     * */
    STOCK_ZHI_SHU("stock_zhi_shu","股票指数"),
    /**
     *
     * */
    SLOGAN("slogan","猜广告"),

    /**
     *
     * */
    PROVERB("proverb","谚语"),
    /**
     *
     * */
    ZIMI("zimi","字谜"),
    /**
     *
     * */
    WEN_DA("wenda","一站到底");

    /**
     * 日历提示
     */
    public static final String LUNAR_HINT =LUNAR.codeName()+"后面写"+HUANG_LI_DAY+"括号里面其中一个或者指定(yyyy-MM-dd)"+ DateUtil.formatDate(new Date())+"这样的日期哦!";
    /**
     * 藏头诗提示
     */
    public static final String CANGTOUSHI_HINT =CANGTOUSHI.codeName()+"后面要2-8个数字才可以哦!";

    @EnumValue
    private String code;
    private String name;

    RobotFeatureEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static Map<String, RobotFeatureEnum> toMap(){
        Map<String, RobotFeatureEnum> toReturn = new HashMap<>();
        RobotFeatureEnum[] values = RobotFeatureEnum.values();
        for(RobotFeatureEnum val:values){
            toReturn.put(val.code, val);
        }
        return toReturn;

    }
    @JsonCreator
    public static RobotFeatureEnum ofValue(String value){
        return toMap().get(value);
    }
    public static String code2name(String code) {
        RobotFeatureEnum[] values = RobotFeatureEnum.values();
        for (RobotFeatureEnum val : values) {
            if(StringUtils.equals(val.codeType(),code)){
                return val.codeName();
            }
        }
        return null;
    }

    public static String name2code(String name) {
        RobotFeatureEnum[] values = RobotFeatureEnum.values();
        for (RobotFeatureEnum val : values) {
            if(StringUtils.equals(val.codeName(),name)){
                return val.codeType();
            }
        }
        return null;
    }

    public String getDomainId() {
        return RobotFeatureEnum.class.getName();
    }

    @JsonValue
    public String codeType() {
        return this.code;
    }

    public String codeName() {
        return this.name;
    }
}
